<?php

if(file_exists(dirname(__FILE__)."/includes/application_top.php")) {
	require_once(dirname(__FILE__)."/includes/application_top.php");
	require_once(dirname(__FILE__)."/../includes/m1_common_functions.php");
	
} elseif(file_exists(dirname(__FILE__).'/../auth.php')) {
	require_once(dirname(__FILE__)."/auth.php");
	require_once (dirname(__FILE__)."/../include/security.php");
	require_once(dirname(__FILE__)."/../include/m1_common_functions.php");
}
/*
function getFile($fileName){
    $sourceFileName = $fileName['full_path'];
    $origFileName = './m1/services' . $fileName['local_path'];
    $fp = fopen($sourceFileName, "rb");
    $fd = fopen($origFileName, "w");
    if ($fp && $fd) {
        while (!feof($fp)) {
            $st = fread($fp, 4096);
            fwrite($fd, $st);
        }
    }
    @fclose($fp);
    @fclose($fd);
}


$sourceFileName = 'http://localhost/m1_services/getFiles.php';

$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $sourceFileName );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ;
$content = curl_exec( $ch );
$response = curl_getinfo( $ch );
curl_close ( $ch );
if ($response["http_code"] == '200'){
    $filelist = unserialize($content);
    foreach ($filelist as $fileName){
        getFile($fileName);
    }

}
*/
$m1ServicesContent = '
<style type="text/css">
            #m1_additional{
                    width: 500px;
                    border: 0;
                    margin: 0;
                    padding: 0;
            }
</style>
<script type="text/javascript">
	var int=self.setInterval("adjustM1FrameHeight()",2000);

    function adjustM1FrameHeight() {
			var iframe = document.getElementById("m1_additional");
            if (iframe) {
                    var iframeWin = iframe.contentWindow;
                    if (iframeWin.document.body) {
						iframe.height = iframeWin.document.body.clientHeight+25;
                    }
            }
    };
</script>
<div style="text-align: center;"><iframe src="./m1/services/services.php" height="1000px" id="m1_additional" onload="adjustM1FrameHeight();"></iframe></div>';

if (isset($smarty)) {
	$smarty->assign('main','m1_services');
	$smarty->assign('m1_services_content',$m1ServicesContent);
	if (file_exists($xcart_dir.'/modules/gold_display.php') && is_readable($xcart_dir.'/modules/gold_display.php')) {
		include $xcart_dir.'/modules/gold_display.php';
	}
	func_display("admin/home.tpl", $smarty);
	
} else {
?>
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>

<?php
if(function_exists(tep_get_version)) { //Oscommerce >=2.3
    $ext_path = (ENABLE_SSL_CATALOG ? HTTPS_CATALOG_SERVER : HTTP_CATALOG_SERVER) . DIR_WS_CATALOG;
?>
<!--[if IE]><script type="text/javascript" src="<?php echo $ext_path; ?>ext/flot/excanvas.min.js"></script><![endif]-->

<link rel="stylesheet" type="text/css" href="<?php echo $ext_path; ?>ext/jquery/ui/redmond/jquery-ui-1.8.6.css">
<script type="text/javascript" src="<?php echo $ext_path; ?>ext/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<?php echo $ext_path; ?>ext/jquery/ui/jquery-ui-1.8.6.min.js"></script>
<script type="text/javascript" src="<?php echo $ext_path; ?>ext/flot/jquery.flot.js"></script>
<?php
}
?>

<script type="text/javascript" language="javascript" src="includes/general.js"></script>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<!--
<style type="text/css">
.dynamic-tab-pane-control h2 {
    text-align: center;
    width:      auto;
}

.dynamic-tab-pane-control h2 a {
    display:    inline;
    width:      auto;
}

.dynamic-tab-pane-control a:hover {
    background: transparent;
}

tr.menu1 {
			font-family: Verdana,Arial,sans-serif;
			font-size: 10px;
			color: rgb(0, 0, 0);
			background-color: rgb(230, 230, 230);
	}

	.text1 {
			font-family: Verdana,Arial,sans-serif;
			font-size: 10px;
			color: rgb(0, 0, 0);
			background-color: rgb(230, 230, 230);
	}

	.text1edit {
			font-family: Verdana,Arial,sans-serif;
			font-size: 10px;
			color: rgb(0, 0, 0);
			background-color: rgb(245, 245, 245);
	}

	tr.menu2 {
			font-family: Verdana,Arial,sans-serif;
			font-size: 10px;
			color: rgb(0, 0, 0);
			background-color: rgb(250, 250, 250);
	}

	.text2 {
			font-family: Verdana,Arial,sans-serif;
			font-size: 10px;
			color: rgb(0, 0, 0);
			background-color: rgb(250, 250, 250);
	}

	.text2edit {
			font-family: Verdana,Arial,sans-serif;
			font-size: 10px;
			color: rgb(0, 0, 0);
			background-color: rgb(245, 245, 245);
	}

</style>
-->
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<?php
if (!function_exists(tep_get_version)) { //Not Oscommerce >=2.3
?>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
    <tr>
        <td width="<?php echo BOX_WIDTH; ?>" valign="top">
            <table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
                <!-- left_navigation //-->
                <?php
				if(!M1_Loader::is_zencart()) {
                    require(DIR_WS_INCLUDES . 'column_left.php');
                }
                ?>
                <!-- left_navigation_eof //-->
            </table>
        </td>

        <!-- body_text //-->
        <td width="100%" valign="top">
<?php
} else {
    include(DIR_WS_INCLUDES . 'column_left.php');
    echo "<div id=\"contentText\">\n";
}
?>
            <table border="0" width="100%" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="100%"><br>
 						<?php echo $m1ServicesContent; ?>
                    </td>
                </tr>
                <tr>
                    <td>
<!-- header_eof //-->

<?php
if (!function_exists(tep_get_version)) { //Not Oscommerce >=2.3
?>
        </td>
    </tr>
</table>
<?php
} else {
    echo "</div>\n";
}
?>
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php
	require(DIR_WS_INCLUDES . 'application_bottom.php');
}

?>
